#@layout()
#define script()
<script>

    $.ajax({
        url: "http://47.105.208.60:8080/wechat-api/article/findSpecialtyNo?bId=#(id ??)"
        //url: "http://localhost:8080/wechat-api/article/findSpecialtyNo?bId=#(id ??)"
        , dataType: 'json'
        , type: 'get'
        , success: function (data) {
            console.log("+++++++")
            console.log(data);
            if (data != null && data != "") {
                var infos = data.info;
                $("tbody").html("");
                $(infos).each(function () {
                    var content = "<tr id='tr' class='tr'>";
                    content += "<td></td>";
                    content += "<td>" + this.title + "</td>";
                    content += "<td></td>";
                    content += "<td></td>";
                    content += "<td></td>";
                    content += "<td><button onclick='binding(\"" + this.id + "\")'>选择</button></td>";
                    content += "</tr>";
                    $("tbody").append($(content));

                })
            } else {
                console.log("========")
                alert("操作失败");//请求传输失败回调函数
            }
        }
        , error: function (msg) {
            console.log("----------")
            alert("ajax错误"); //错误信息

        }
    });

    function no() {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/article/findSpecialtyNo?bId=#(id ??)"
            //url: "http://localhost:8080/wechat-api/article/findSpecialtyNo?bId=#(id ??)"
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {
                console.log("+++++++")
                console.log(data);
                if (data != null && data != "") {
                    $("tbody").html("");
                    var infos = data.info;
                    $(infos).each(function () {
                        var content = "<tr id='tr' class='tr'>";
                        content += "<td></td>";
                        content += "<td>" + this.title + "</td>";
                        content += "<td></td>";
                        content += "<td></td>";
                        content += "<td></td>";
                        content += "<td><button onclick='binding(\"" + this.id + "\")'>选择</button></td>";
                        content += "</tr>";
                        $("tbody").append($(content));

                    })
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert("ajax错误"); //错误信息

            }
        });
    }

    function yes() {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/article/findSpecialtyYes?bId=#(id ??)"
            //url: "http://localhost:8080/wechat-api/article/findSpecialtyYes?bId=#(id ??)"
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {
                console.log("+++++++")
                console.log(data);
                if (data != null && data != "") {
                    $("tbody").html("");
                    var infos = data.info;
                    $(infos).each(function () {
                        var content = "<tr id='tr' class='tr'>";
                        content += "<td></td>";
                        content += "<td>" + this.title + "</td>";
                        content += "<td></td>";
                        content += "<td></td>";
                        content += "<td></td>";
                        /*  content += "<td>/!*<button onclick='del(\"" + this.id + "\")'>取消菜品</button>*!/</td>";*/
                        content += "<td></td>";
                        content += "</tr>";
                        $("tbody").append($(content));

                    })
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert("没有数据"); //错误信息

            }
        });
    }

    function binding(id) {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/specialty/save?bId=#(id ??)&&sId=" + id
            //url: "http://localhost:8080/wechat-api/specialty/save?bId=#(id ??)&&sId=" + id
            , dataType: 'json'
            , success: function (data) {
                if (data.code == 0) {
                    alert("绑定成功");
                    window.location.reload();
                }
                else
                {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }
        });
    }
</script>

#end

#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            特产管理
            <!--<small>Article Management</small>-->
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="box box-primary">
                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                <label>
                    <button onclick="no()">未选择特产</button>
                </label>
                &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp;
                <label>
                    <button onclick="yes()">已选择特产</button>
                </label>
            </div>
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-body ">

                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th style="width: 10px">
                                    <input name="dataItem" onchange="checkAll(this)" type="checkbox" value="0"/>
                                </th>
                                <th>特产名称</th>
                                <th>作者</th>
                                <th>分类</th>
                                <th>标签</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-sm-12">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>

    </section>


</div>
#end
